<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>打印预览</TITLE>
<style>	
	.userData{behavior:url(#default#userData);}

</style>
<SCRIPT language=javaScript src="/webprint/billprint/public.js"></SCRIPT>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
var tableHtml=window.dialogArguments[0]
var BillName=window.dialogArguments[1]
//节点内容串
var SendParameter=window.dialogArguments[2]		

var number=1
var screenWidth=window.dialogArguments[3]
var screenHeight=window.dialogArguments[4]
var repWidth=210
var repHeight=297
var printCopys=3
var topwindage=0
var leftwindage=0
var printformat="套打"
var offsetAdjust=0
var pxRatemm=3.78
//上面这些变量值的运算在loadLabelData函数中进行


var lastnodenumber=0//第二级子节点的个数



function window_onload() {
	//将初始设置信息存入缓存中
	var strPageSet=window.dialogArguments[5]
	if (strPageSet!=""){
		SaveUserData("billprint",BillName,strPageSet)		
	}
	var strPageAll=window.dialogArguments[6]
	if (strPageAll!="") {
		SaveUserData("node",BillName,strPageAll)
	}
	loadLabelData("打印预览",screenWidth,screenHeight)
	//alert(offsetAdjust)
	//pxRatemm=3.78*(297-offsetAdjust)/297
	//alert(pxRatemm)
}
function window_onbeforeprint() {
	//alert("window_onbeforeprint")	
	if (printformat=="套打"){ //套打
		//隐藏背景
		try {
			billstyle.style.display="none"
		}
		catch (e) {}
	}
	if (printformat=="打印样式"){ //只打印背景
		//隐藏各个标签,每个标签的id=fcsoft_node
		var celSpan=document.all.item("fcsoft_node")
		var spanNumber=celSpan.length
		for (var i=0;i<spanNumber;i++){
			celSpan[i].style.display="none"
		}		
	
	}
	//隐藏工具条	
	toolbar.style.display ="none"
	//计算大框的高度和宽度
	result.style.width ="" 
	result.style.height ="" 
	result.style.position=""
	
	var pageTop=0 //每页间距
	pageTop=offsetAdjust*pxRatemm

	if (printCopys==0)printCopys=1
	//去掉每页之间的页间距,边框线
	var div1=document.all.tags("div")
	for (var i=0;i<number;i++){	
		div1[i].style.top=repHeight*pxRatemm*i-topwindage*pxRatemm-pageTop*i	//*Math.floor(i/printCopys)
		div1[i].style.left=-leftwindage*pxRatemm
		div1[i].style.width=""
		div1[i].style.height=""
		
		div1[i].style.borderTopWidth=0
		div1[i].style.borderLeftWidth=0
		div1[i].style.borderRightWidth=0
		div1[i].style.borderBottomWidth=0
	}	
	//sfasd
}
function window_onafterprint() {		
	//alert("window_onafterprint")	
	
	if (printformat=="套打"){ //套打
		//恢复背景
		try {
			billstyle.style.display="block"
		}
		catch (e) {}
	}
	if (printformat=="打印样式"){ //只打印背景
		//恢复各个标签,每个标签的id=fcsoft_node
		var celSpan=document.all.item("fcsoft_node")
		var spanNumber=celSpan.length
		for (var i=0;i<spanNumber;i++){
			celSpan[i].style.display="block"
		}		
	
	}
	//恢复工具条	
	toolbar.style.display ="block"

	//计算大框的高度和宽度
	//result.style .overflow ="scroll"
	result.style.height =screenHeight-25
	result.style.width =screenWidth-5		
	result.style.position="absolute"
	
	//恢复每页之间的页间距,边框线
	var div1=document.all.tags("div")	
	var newDivtop=50
	for (var i=0;i<number;i++){		
		div1[i].style.top=newDivtop
		newDivtop=newDivtop+repHeight*pxRatemm+20	
		if ((screenWidth-repWidth*pxRatemm)*0.5-5>0){
			div1[i].style.left=(screenWidth-repWidth*pxRatemm)*0.5-5
		}
		if ((screenWidth-repWidth*pxRatemm)*0.5-5<=0){	
			div1[i].style.left=0
		}
		div1[i].style.width=repWidth*pxRatemm
		div1[i].style.height=repHeight*pxRatemm

		div1[i].style.borderTopWidth=2
		div1[i].style.borderLeftWidth=2
		div1[i].style.borderRightWidth=2
		div1[i].style.borderBottomWidth=2

	}	

}
function printOK_onclick() {
	window.print ()
}
function CloseWindow_onclick() {
	self.close ()	
}
function autoPrint()
{
	try
	{
		if(window.dialogArguments[7] == true)
		{
			printOK_onclick();
			CloseWindow_onclick(); // 直接打印不弹出预览窗口
		}
	}
	catch(err)
	{
	
	}
}
//-->
</SCRIPT>
</HEAD>
<BODY  bgColor=lightgrey LANGUAGE="javascript" onafterprint="return window_onafterprint()" onbeforeprint="return window_onbeforeprint()" onload =" window_onload();autoPrint();" >
<label id=result style="HEIGHT: 550px; LEFT: 0px; OVERFLOW: scroll; POSITION: absolute; TOP: 0px; WIDTH: 795px"></label>
<TABLE id=toolbar WIDTH="98%" BORDER=1 CELLSPACING=0 CELLPADDING=0  bgcolor=silver style="POSITION: absolute">
	<TR>
	<TD width=50><INPUT id=printOK type=button value="打&nbsp;&nbsp;印" LANGUAGE=javascript onclick="return printOK_onclick()"></TD>
	<TD width=1000></TD>
	<TD><INPUT id=CloseWindow type=button value="关&nbsp;闭" LANGUAGE=javascript onclick="return CloseWindow_onclick()"></TD>
		
	</TR>
</TABLE>

</BODY>
</HTML>
